
import java.util.Random;


public class Measurements {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		

		
		for (int i = 1; i <= 10; i++) {
		
			Random random = new Random();
			RBTree tree = new RBTree();
			int maxColorChanges = 0;
			float maxAverageColorChanges = 0;
			int currentNumOfColorChanges;
			float sumOfColorChanges = 0;
			int numOfInserts = 0;
			int randomInt;
			
			while (tree.size() < 50000) {
				randomInt = random.nextInt(2000000000);
				
				if (!(tree.search(randomInt))) {
					
					numOfInserts++; //increase number of inserts
					
					currentNumOfColorChanges = tree.insert(randomInt); //insert the item and retrieve the number of color changes that occurred
					
					sumOfColorChanges += currentNumOfColorChanges;
					
					if (currentNumOfColorChanges > maxColorChanges) {
						maxColorChanges = currentNumOfColorChanges;
					}
					
					if ((sumOfColorChanges/numOfInserts) > maxAverageColorChanges) {
						maxAverageColorChanges = (sumOfColorChanges/numOfInserts);
					}
					
				}
			}
			
			System.out.println("Run " + i + " results:\n"
					+ "Maximum number of average color changes: " + maxAverageColorChanges + "\n"
					+ "Maximum number of color changes: " + maxColorChanges + "\n\n");

			
		}
		
				
	}


}
